#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <unordered_map>
#include <vector>
#include <set>
#include <queue>

using namespace std;
using LL = long long;
using PII = pair<int, int>;

const int N = 110;

int n, m;
int p[N];


int find(int x){
    if(x != p[x]){
        p[x] = find(p[x]);
    }
    return p[x];
}

int main(){
#ifdef LOCALFLAG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif


    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> n >> m;
    for(int i = 1; i <= n; i ++) p[i] = i;

    int a, b;
    for(int i = 1; i <= m; i ++){
        cin >> a >> b;
        int fa = find(a), fb = find(b);
        if(fa !=  fb){
            n --;
            p[fa] = fb;
        }
    }

    cout << n << '\n';



    return 0;
}